Repository navigation
feat(DiffViewer): one collapsible prop configures the file disclosure, as on Banner - #13699
Conversation
…, as on Banner DiffViewer's file disclosure takes one named feature prop, `collapsible?: boolean | CollapsibleConfig`, in place of `isCollapsible`, `isCollapsed`, `defaultIsCollapsed` and `onCollapsedChange`. The config is the shared one Banner and Collapsible take (`defaultIsOpen`, `isOpen`, `onOpenChange`), and the shared `useCollapsible` hook holds the state. Omitted or `true` keeps today's default: collapsible, starting open. No behavior or visual change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/DiffViewer · Storybook | 97.4 kB (+170 B) · 2.3 kB CSS (0) | 2,701 (−6) | — · ✓ · ✓ |
Package size: no published package changed; no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved pending CI: the deferred build and test jobs have not run on this head yet; they run once review passes, before merge.
DiffViewer's disclosure now takes Banner's collapsible?: boolean | CollapsibleConfig through the shared useCollapsible hook, the default stays collapsible and open, and both in-repo callers move to the new prop. There are no blocking findings.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: one
collapsibleprop typed like Banner's replaces the four DiffViewer disclosure props: verified (packages/lab/src/DiffViewer/DiffViewer.tsx:207,packages/core/src/Banner/Banner.tsx:192). - Claim: omitted or
truestays collapsible and starts open: verified (DiffViewer.tsx:1311,packages/core/src/Collapsible/useCollapsible.ts:104). - Claim: a controlled caller passes
isOpen, the negation of the old collapsed value, and uncontrolledonOpenChangefires beside the internal update: verified (useCollapsible.ts:130-136). - Claim: the toggle, its
aria-expandedandaria-controls, and the collapsed render are unchanged: verified (DiffViewer.tsx:2068-2134). - Claim: no behavior or visual change: verified from the code, which derives the same collapsed state; the committed before and after frames are identical files per pair.
- Claim: the config keys match Banner's and Collapsible's: verified (Banner takes the config as one prop; Collapsible takes the same three keys as separate props,
packages/core/src/Collapsible/Collapsible.tsx:249-272). - Claim: Lab is canary-only and the story and the perf sandbox page are the only in-repo callers to move: verified (
packages/lab/package.json; no other caller passes the removed props). - Claim: the cited architecture clauses say what the description quotes (named feature props such as
collapsibleare fine; one API per job; Lab stays out of the API delta): verified against the current record. - Claim: the tests cover uncontrolled toggling,
defaultIsOpen: false, a controlledisOpen: false, andcollapsible={false}: verified (DiffViewer.test.tsx:199,:221,:262,:274). - Claim: 94 DiffViewer tests pass: the head has 94 test cases in that folder; the run itself awaits CI.
- Claim: lint and typecheck are clean: CI's lint and typecheck (Lab and Storybook) passed on this head.
- Claim: newer base commits touch none of these files: verified.
- File
packages/lab/src/DiffViewer/DiffViewer.tsx: clear. - File
packages/lab/src/DiffViewer/DiffViewer.test.tsx: clear. - File
packages/lab/src/DiffViewer/DiffViewer.doc.mjs: clear. - File
apps/storybook/stories/DiffViewer.stories.tsx: clear. - File
apps/sandbox/src/app/(fullscreen)/pages/diffviewer-perf/page.tsx: clear.
Primary intent
DiffViewer's file disclosure takes the system's one API for a disclosure before DiffViewer moves to Core: one named feature prop,
collapsible?: boolean | CollapsibleConfig, shaped like Core Banner'scollapsible, in place of four DiffViewer-only props. No behavior or visual change. This is not a bug fix, a new capability, a documentation correction, or a record, soother.mdfits: it changes the shape of a Lab API and keeps what it does.User or maintainer impact
CollapsibleConfig(defaultIsOpen,isOpen,onOpenChange).isCollapsible,isCollapsed,defaultIsCollapsed, oronCollapsedChangechange their call. Lab is canary-only and promises no stability; the two callsites in this repository, a story and the DiffViewer perf sandbox page, move here.aria-expandedandaria-controls, and the collapsed render are the same.Problem and solution fit
DiffViewerPropsreplaces the four props withcollapsible?: boolean | CollapsibleConfig(defaulttrue), and the shareduseCollapsiblehook holds the open state.ViewedTogglestory, and the DiffViewer perf sandbox page move to the new prop.Defaults and compatibility: omitted or
trueis collapsible and starts open, as before. The polarity is open, as on Banner, so a controlled caller keepsisOpen, the negation of the oldisCollapsed. Uncontrolled,onOpenChangefires beside the internal update, asonCollapsedChangedid. The caller makes no new decision.Authority
architecture:public-component-apiINV19: a costly feature plugs in or takes a named feature prop, and "named props for features are also fine (likecollapsible)".CollapsibleConfigis the existing API for a disclosure's state, and Banner'scollapsible?: boolean | CollapsibleConfig(packages/core/src/Banner/Banner.tsx) is the shape this follows. DiffViewer keeps the hook's default, open, because it starts open today; Banner overrides it to start closed.Change and evidence
DiffViewer.test.tsx: uncontrolled toggling reports throughonOpenChange;{defaultIsOpen: false}starts collapsed and opens from the header (new case); a controlled{isOpen: false}only reportstrueand stays collapsed;collapsible={false}renders the path as plain text and shows the hunks.#storybook-root. Every pair is pixel-identical (pixelmatch, threshold 0).Viewed toggle unchecked, also identical: before, after.
The move of DiffViewer to Core, #13700, is stacked on this pull request.
Scope
Components: DiffViewer
Testing
pnpm vitest run packages/lab/src/DiffViewer: 94 passed.ASTRYX_STRICT_LINT=1 eslintand Prettier on the changed files: clean.pnpm review:pre: 0 findings. The pre-commitpnpm check:repo,pnpm check:knowledgeincluded: clean.pnpm storybook:build, then the screenshots above.Local runs used main at 0744c42; the branch sits on 4f4b365, whose newer commits touch none of these files.